import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
export function listTeachingClassInfoPage (data) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/listTeachingClassInfoPage',
        method: 'post',
        data
    });
}
/**
 * 补缓考成绩录入页面获取列表
 * @param {*} data
 */
export function delayExamListPage(data = {}) {
    let paramUrl = '';
    for (var key in data) {
        if (data[key] === '') {
            continue;
        }
        paramUrl += `${key}=${data[key]}&`;
    }
    return fetch({
        url: '/api/scoremanagementservice/delayExam/delayExamListPage?' + paramUrl,
        method: 'get'
    });
}
export function isCanEnterScore (data) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/isCanEnterScore',
        method: 'get',
        params: data
    });
}
// 获取未发布
export function listCourseScorePage (data) {
    return fetch({
        url: '/api/scoremanagementservice/courseScoreChange/listCourseScorePage',
        method: 'POST',
        data
    });
}
// 获取全部课程
export function listAllCourseScorePage (data) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/listAllCourseScorePage',
        method: 'POST',
        data
    });
}
// 指定教师保存
export function setImporter (data) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/setImporter',
        method: 'POST',
        data
    });
}
/**
 * 指定审核人
 * @param {*} data
 */
export function setAuditTeacher(data = {}) {
    return fetch({
        url: '/api/scoremanagementservice/delayExam/enterPersonSetting',
        method: 'post',
        data
    });
}
/** *
 * 根据课程代码或者名称搜索相应课程
 *
 * */
export function searchCourses (data) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/getCourseListByCalendarId',
        method: 'POST',
        data
    });
}
/**
 * 取消指定教师
 *  */
export function canceldelayPoint(data = {}) {
    return fetch({
        url: '/api/scoremanagementservice/delayExam/enterPersonCancle',
        method: 'PUT',
        data
    });
}

/**
 * 取消补缓考页面指定教师
 *  */
export function cancelAppoint(data) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/cancelImporter?teachingClassIds=' + data,
        method: 'GET'
    });
}


/**
 *成绩录入统计-》成绩录入汇总
 *
 */

export function listScoreEnterCollegeCount(data) {
    return fetch({
        url: '/api/scoremanagementservice/studentScoreCount/listScoreEnterCollegeCount',
        method: 'POST',
        data
    });
}

/**
 * 成绩录入统计-》学院成绩录入汇总
 */
export function listScoreEnterCourseCount(data) {
    return fetch({
        url: '/api/scoremanagementservice/studentScoreCount/listScoreEnterCourseCount',
        method: 'POST',
        data
    });
}
/**
 * 成绩录入统计-》未录入学生名单
 */
export function listNoEnterScoreStudent(data) {
    return fetch({
        url: '/api/scoremanagementservice/studentScoreCount/listNoEnterScoreStudent',
        method: 'POST',
        data
    });
}
/**
 * 判断成绩是否可支持录入
 * params  calendarId:学期id  faculty：开课学院代码
 */
export function isCanRecoedScore(calendarId, faculty, courseCode, teachingClassId) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/isCanEnterScore?calendarId=' + calendarId + '&faculty=' + faculty + '&courseCode=' + courseCode + '&teachingClassId=' + teachingClassId,
        method: 'GET'
    });
}

export function exportGeneralTable(idList) {
    return fetch({
        url: '/api/scoremanagementservice/teachingClassScore/batchExportTotalMarkScorePdf?language=cn',
        method: 'post',
        responseType: 'blob',
        data: idList
    }).then(res => {
        if(idList.length > 1){
            UTILS.downloadFile(res, '总评成绩表.zip', 'application/zip;charset=utf-8');
        }else{
            UTILS.downloadFile(res, `总评成绩表${idList[0]}.pdf`, 'application/vnd.ms-pdf;charset=utf-8');
        }
    })
}
